package com.itheima.app.controller;

import com.itheima.app.manager.UserLikeManager;
import com.itheima.vo.PageBeanVo;
import com.itheima.vo.RecommendUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class UserLikeController {

    @Autowired
    private UserLikeManager userLikeManager;

    /**
     * 探花查询卡片
     */
    @GetMapping("/cards")
    public List<RecommendUserVo> findTanhuaCards(
            @RequestParam(defaultValue = "1", name = "page") Integer pageNumber,
            @RequestParam(defaultValue = "10", name = "pagesize") Integer pageSize
    ) {
        //查询推荐的好友信息
        PageBeanVo pageBeanVo = userLikeManager.findRecommendUser(1, 20);
        return (List<RecommendUserVo>) pageBeanVo.getItems();
    }

    /**
     * 喜欢
     *
     * @param userLikeId
     * @return
     */
    @GetMapping("/{id}/love")
    public Map love(
            @PathVariable("id") Long userLikeId

    ) {
        userLikeManager.love(userLikeId);
        return null;
    }

    /**
     * 探花-不喜欢
     */
    @GetMapping("/{id}/unlove")
    public void unlove(@PathVariable("id") Long likeUserId) {
        userLikeManager.unlove(likeUserId);
        //return ResponseEntity.ok(null);
    }
}
